<template>
  <view class="page-body">
   <u-navbar :is-back="false" title="付款记录添加"
     title-size="30"
     :background="{background:'#2B88FE' }"
     title-color="#fff">
     <div class="head_icon">
       <u-icon @click="$api.handleBackTo"
         name="arrow-left" color="#fff"
         size="36">
       </u-icon>
       <u-icon @click="$api.handleHomeTo"
         name="home" color="#fff" size="36">
       </u-icon>
     </div>
   </u-navbar>
    <view class="clist x-row">
      <view class="x-col-center cname">
        未付金额
      </view>
        
      <view class="rmb x-col-center">
        {{detail.fNoPayMoney}} 元
      </view>
    </view>
	<view class="clist x-row">
	  <view class="x-col-center cname">
	    付款金额
	  </view>
	  <input placeholder="请输入" v-model="form.PayMoney " type="digit"
	    class="x-col x-col-center "></input>
	  <view class="rmb x-col-center">
	    元
	  </view>
	</view>
	<view class="h16">
	
	</view>
	
	<view class="clist x-row">
	  <view class="x-col-center cname">
	    付款方式
	  </view>
	  <div @click="signClient=true" class="boxFlex">
	    {{SignText}}<u-icon name="arrow-right" color="#999">
	    </u-icon>
	  </div>
	   <u-picker mode="selector" v-model="signClient" :range="PayTypeList" @confirm="bindPayType">
	   </u-picker>
	</view>
	<view class="h16">
	
	</view>
	<view class="clist x-row">
	  <view class="x-col-center cname">
	    抹零
	  </view>
	  <input placeholder="请输入" v-model="form.NoPay " type="digit"
	    class="x-col x-col-center "></input>
	  <view class="rmb x-col-center">
	    元
	  </view>
	</view>
	<view class="h16">
	
	</view>
    <view class="infos whiteBg">
      <view class="clist x-row ">
        <view class="x-col-center cname" style="width: 300rpx;">
          付款说明
        </view>
      </view>
      <textarea v-model="form.PayInfo" class="txt" placeholder="请在此输情况说明…"></textarea>

      <view class="clist x-row">
        <view class="x-col-center cname">
          付款图片
        </view>
      </view>
      <u-upload ref="uUpload" :header="header" max-count="8" name="file" :action="action"
        :auto-upload="true">
      </u-upload>
    </view>
    <view :style="{height:height}"></view>
    <view class="viewbbutton" :style="{height:height}">
      <button class="sendBomBtn" @click="submit">提 交</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      form: {
	    MrkId: this.id,
	    OrderId: this.willid,
	    WillId: this.willid,
	    PayInfo: '',
	    PayPic: '',
	    PayMoney: 0,
		PayOrBack:1,
		NoPay: 0,
		PayType: 1,
		OrderOrWill:2
      },
	   clineOnce:true,
	  detail: {},
	   willid: 0,
	 id: 0,
      header: {
        token: uni.getStorageSync('token')
      },
      height: this.but_height(),
      action: this.urlimg + 'api/Upfile/PostImgFile',
      clist: [],
      isAllList: 1,
	  signClient: false,
	  SignText: '请选择支付方式',
      page: 1,
      status: 'loading',
	  PayTypeList: ['现金','微信'],
      loading: true
    }
  },
  onLoad(e) {
    uni.setNavigationBarTitle({
      title: '新增付款记录'
    })
	 this.id = Number(e.id)
	   this.willid = Number(e.willid)
	 this.$axios('api/MrkNoPayWill/GetDetail', 'post', { value: e.willid }).then(res => {
	   this.detail = res.Value
	   this.form.PayMoney=this.detail.fNoPayMoney
	 })
  },
  methods: {
    // user/submit_apply 			新增报销
    submit() {
		if (!this.clineOnce)
		{
		  uni.showToast({
		    title: '信息提交中，请勿重复提交',
		    icon: 'none',
		    duration: 2000
		  })
		  return false
		}
		this.clineOnce = false
		 this.form.MrkId=this.id
		  this.form.OrderId=this.detail.fOrderId
		  this.form.WillId=this.willid
		//   console.log("pic", this.$refs.uUpload.lists)
        this.form.PayPic = this.$api.getreqImg(this.$refs.uUpload.lists)
        this.$axios('api/PayInfo/AddCollectionSave', 'post', { value: this.form }).then(res => {
		  if (!res.Success) {
		    uni.showToast({
		      title: '提交失败：'+res.Message,
		      icon: 'none',
		      duration: 2000
		    })
			 this.clineOnce = true
		    return false
		  }
		this.clineOnce = true
        this.$api.handleToUrl('提交成功', '/pages/my_customer/PayWillDetail?id='+this.id +'&willid='+this.willid)
      })
    },
	bindPayType(event) {
	  let isSign = Number(event.toString())
	  this.form.PayType = isSign ? 2 : 1
	  this.SignText = isSign ? '微信' : '现金'
	  
	 //  console.log("aaa", this.form.PayType)
	    //  console.log("bbb", this.SignText)
	   
	},
	
  }
}
</script>

<style lang="scss">
.clist {
  padding: 34rpx 32rpx;
  box-sizing: border-box;
  background-color: #ffffff;
  .cname {
    width: 164rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #34404a;
  }

  .rmb {
    font-size: 30rpx;
    font-weight: 400;
    color: #34404a;
  }
}
.infos {
  padding: 0 32rpx;
  .clist {
    padding-left: 0;
    padding-right: 0;
  }
  .txt {
    height: 200rpx;
    background: #f8f9fc;
    border-radius: 16rpx;
    border: 2rpx solid rgba(0, 0, 0, 0.09);
    padding: 22rpx 20rpx;
    box-sizing: border-box;
    width: 100%;
  }
}
.h16 {
  height: 16rpx;
  background-color: #f5f7f9;
}
</style>
